﻿using Sidvall.Collections;

namespace Sidvall.IdentityManager.UI.Entities
{
    public partial class AspNetUsers
    {
        #region Public Members

        #region Name

        public string Name
        {
            get
            {
                return GetClaimValue(Sidvall.Security.ClaimTypes.Name);
            }
            set
            {
                SetClaimValue(Sidvall.Security.ClaimTypes.Name, value);
                OnPropertyChanged(nameof(Name), true, false);
            }
        }

        #endregion
        #region LoginProviderNames

        public string LoginProviderNames
        {
            get
            {
                return this.AspNetUserLogins.JoinToString(System.Environment.NewLine, true, o => o.LoginProvider);
            }
        }

        #endregion

        #region Plugin1ColumnData1

        private string _Plugin1ColumnData1 = null;
        public string Plugin1ColumnData1
        {
            get
            {
                return _Plugin1ColumnData1;
            }
            set
            {
                _Plugin1ColumnData1 = value;
                OnPropertyChanged("Plugin1ColumnData1", true, false);
            }
        }

        #endregion
        #region Plugin1ColumnData2

        private string _Plugin1ColumnData2 = null;
        public string Plugin1ColumnData2
        {
            get
            {
                return _Plugin1ColumnData2;
            }
            set
            {
                _Plugin1ColumnData2 = value;
                OnPropertyChanged("Plugin1ColumnData2", true, false);
            }
        }

        #endregion
        #region Plugin1ColumnData3

        private string _Plugin1ColumnData3 = null;
        public string Plugin1ColumnData3
        {
            get
            {
                return _Plugin1ColumnData3;
            }
            set
            {
                _Plugin1ColumnData3 = value;
                OnPropertyChanged("Plugin1ColumnData3", true, false);
            }
        }

        #endregion
        #region Plugin2ColumnData1

        private string _Plugin2ColumnData1 = null;
        public string Plugin2ColumnData1
        {
            get
            {
                return _Plugin2ColumnData1;
            }
            set
            {
                _Plugin2ColumnData1 = value;
                OnPropertyChanged("Plugin2ColumnData1", true, false);
            }
        }

        #endregion
        #region Plugin2ColumnData2

        private string _Plugin2ColumnData2 = null;
        public string Plugin2ColumnData2
        {
            get
            {
                return _Plugin2ColumnData2;
            }
            set
            {
                _Plugin2ColumnData2 = value;
                OnPropertyChanged("Plugin2ColumnData2", true, false);
            }
        }

        #endregion
        #region Plugin2ColumnData3

        private string _Plugin2ColumnData3 = null;
        public string Plugin2ColumnData3
        {
            get
            {
                return _Plugin2ColumnData3;
            }
            set
            {
                _Plugin2ColumnData3 = value;
                OnPropertyChanged("Plugin2ColumnData3", true, false);
            }
        }

        #endregion
        #region Plugin3ColumnData1

        private string _Plugin3ColumnData1 = null;
        public string Plugin3ColumnData1
        {
            get
            {
                return _Plugin3ColumnData1;
            }
            set
            {
                _Plugin3ColumnData1 = value;
                OnPropertyChanged("Plugin3ColumnData1", true, false);
            }
        }

        #endregion
        #region Plugin3ColumnData2

        private string _Plugin3ColumnData2 = null;
        public string Plugin3ColumnData2
        {
            get
            {
                return _Plugin3ColumnData2;
            }
            set
            {
                _Plugin3ColumnData2 = value;
                OnPropertyChanged("Plugin3ColumnData2", true, false);
            }
        }

        #endregion
        #region Plugin3ColumnData3

        private string _Plugin3ColumnData3 = null;
        public string Plugin3ColumnData3
        {
            get
            {
                return _Plugin3ColumnData3;
            }
            set
            {
                _Plugin3ColumnData3 = value;
                OnPropertyChanged("Plugin3ColumnData3", true, false);
            }
        }

        #endregion
        #region Plugin4ColumnData1

        private string _Plugin4ColumnData1 = null;
        public string Plugin4ColumnData1
        {
            get
            {
                return _Plugin4ColumnData1;
            }
            set
            {
                _Plugin4ColumnData1 = value;
                OnPropertyChanged("Plugin4ColumnData1", true, false);
            }
        }

        #endregion
        #region Plugin4ColumnData2

        private string _Plugin4ColumnData2 = null;
        public string Plugin4ColumnData2
        {
            get
            {
                return _Plugin4ColumnData2;
            }
            set
            {
                _Plugin4ColumnData2 = value;
                OnPropertyChanged("Plugin4ColumnData2", true, false);
            }
        }

        #endregion
        #region Plugin4ColumnData3

        private string _Plugin4ColumnData3 = null;
        public string Plugin4ColumnData3
        {
            get
            {
                return _Plugin4ColumnData3;
            }
            set
            {
                _Plugin4ColumnData3 = value;
                OnPropertyChanged("Plugin4ColumnData3", true, false);
            }
        }

        #endregion
        #region Plugin5ColumnData1

        private string _Plugin5ColumnData1 = null;
        public string Plugin5ColumnData1
        {
            get
            {
                return _Plugin5ColumnData1;
            }
            set
            {
                _Plugin5ColumnData1 = value;
                OnPropertyChanged("Plugin5ColumnData1", true, false);
            }
        }

        #endregion
        #region Plugin5ColumnData2

        private string _Plugin5ColumnData2 = null;
        public string Plugin5ColumnData2
        {
            get
            {
                return _Plugin5ColumnData2;
            }
            set
            {
                _Plugin5ColumnData2 = value;
                OnPropertyChanged("Plugin5ColumnData2", true, false);
            }
        }

        #endregion
        #region Plugin5ColumnData3

        private string _Plugin5ColumnData3 = null;
        public string Plugin5ColumnData3
        {
            get
            {
                return _Plugin5ColumnData3;
            }
            set
            {
                _Plugin5ColumnData3 = value;
                OnPropertyChanged("Plugin5ColumnData3", true, false);
            }
        }

        #endregion
        #region Plugin6ColumnData1

        private string _Plugin6ColumnData1 = null;
        public string Plugin6ColumnData1
        {
            get
            {
                return _Plugin6ColumnData1;
            }
            set
            {
                _Plugin6ColumnData1 = value;
                OnPropertyChanged("Plugin6ColumnData1", true, false);
            }
        }

        #endregion
        #region Plugin6ColumnData2

        private string _Plugin6ColumnData2 = null;
        public string Plugin6ColumnData2
        {
            get
            {
                return _Plugin6ColumnData2;
            }
            set
            {
                _Plugin6ColumnData2 = value;
                OnPropertyChanged("Plugin6ColumnData2", true, false);
            }
        }

        #endregion
        #region Plugin6ColumnData3

        private string _Plugin6ColumnData3 = null;
        public string Plugin6ColumnData3
        {
            get
            {
                return _Plugin6ColumnData3;
            }
            set
            {
                _Plugin6ColumnData3 = value;
                OnPropertyChanged("Plugin6ColumnData3", true, false);
            }
        }

        #endregion
        #region Plugin7ColumnData1

        private string _Plugin7ColumnData1 = null;
        public string Plugin7ColumnData1
        {
            get
            {
                return _Plugin7ColumnData1;
            }
            set
            {
                _Plugin7ColumnData1 = value;
                OnPropertyChanged("Plugin7ColumnData1", true, false);
            }
        }

        #endregion
        #region Plugin7ColumnData2

        private string _Plugin7ColumnData2 = null;
        public string Plugin7ColumnData2
        {
            get
            {
                return _Plugin7ColumnData2;
            }
            set
            {
                _Plugin7ColumnData2 = value;
                OnPropertyChanged("Plugin7ColumnData2", true, false);
            }
        }

        #endregion
        #region Plugin7ColumnData3

        private string _Plugin7ColumnData3 = null;
        public string Plugin7ColumnData3
        {
            get
            {
                return _Plugin7ColumnData3;
            }
            set
            {
                _Plugin7ColumnData3 = value;
                OnPropertyChanged("Plugin7ColumnData3", true, false);
            }
        }

        #endregion

        // Claims
        #region GetClaimValue

        public string GetClaimValue(string claimType)
        {
            return Sidvall.IdentityManager.UI.SystemContext.Current.EntityFacade.AspNetUsersManager.GetClaimValue(this, claimType);
        }
        public string GetClaimValue(string claimType, string defaultValue)
        {
            return Sidvall.IdentityManager.UI.SystemContext.Current.EntityFacade.AspNetUsersManager.GetClaimValue(this, claimType, defaultValue);
        }

        #endregion
        #region SetClaimValue

        public bool SetClaimValue(string claimType, string value)
        {
            if (Sidvall.IdentityManager.UI.SystemContext.Current.EntityFacade.AspNetUsersManager.SetClaimValue(this, claimType, value))
            {
                OnPropertyChanged(nameof(AspNetUserClaims), true, false);
                return true;
            }
            return false;
        }

        #endregion
        #region RemoveClaim

        public bool RemoveClaim(string claimType)
        {
            if (Sidvall.IdentityManager.UI.SystemContext.Current.EntityFacade.AspNetUsersManager.RemoveClaim(this, claimType))
            {
                OnPropertyChanged(nameof(AspNetUserClaims), true, false);
                return true;
            }
            return false;
        }

        #endregion
        #region HasClaim

        public bool HasClaim(string claimType)
        {
            return Sidvall.IdentityManager.UI.SystemContext.Current.EntityFacade.AspNetUsersManager.HasClaim(this, claimType);
        }

        #endregion

        #endregion
    }
}